<?php

namespace app\index\controller;
use think\Exception;
use think\Loader;
use think\Db;
use think\Session;

use app\index\controller\common as common;
use app\index\model\Assets as assets;
use app\index\model\Assetsversions as Assetsversions;
use app\index\model\Shot as Shot;
use app\index\model\Shot_versions as Shot_versions;
use app\index\validate\IDMustBePositiveInt;
use think\Controller;

class common extends Controller
{


    // /*
    //  * 公共控制器*/
    // public function _initialize(){
    //     //设置子函数 让所有继承Comment的  都必须先登录  否则强制跳到登录页面
    //     $user_id = Session::get('user_id') ;
    //     $user_name = Session::get('user_name') ;
    //     if(!isset($user_id) || !isset($user_name)){
    //         // Go('login/index'); 好像不能用go方法
    //         $this->redirect('login/index');
    //     }
    // }

    /* 根据菜单id查询资产*/
    public function find_assets($id)
    {
        /*验证参数*/
        $validate = new IDMustBePositiveInt();
        list($msg,$result)= $validate->goapiCheck();
        if($msg){
            /*查询目录资产assets*/
            $result = assets::get_data(['category_id'=>$id]) ;
        }
        return returnresult($msg,$result) ; 
    }

    public function find_assets_version($id)
    {
        /*验证参数*/
        $validate = new IDMustBePositiveInt();
        list($msg,$result)= $validate->goapiCheck();
        if($msg){
            $result = Assetsversions::get_data(['assets_id'=>$id]) ;
        }
        return returnresult($msg,$result) ; 
     }
    
    public function screen_find_shot($id){
        /*验证参数*/
        $validate = new IDMustBePositiveInt();
        list($msg,$result)= $validate->goapiCheck();
        if($msg){
            /*查询目录资产assets*/
            $result = Shot::get_data(['Scene_id'=>$id]) ;
        }
        return returnresult($msg,$result) ; 
    }    

    public function shot_find_version($id){
        /*验证参数*/
        $validate = new IDMustBePositiveInt();
        list($msg,$result)= $validate->goapiCheck();
        if($msg){
            /*查询目录资产assets*/
            $result = Shot_versions::get_data(['shot_id'=>$id]) ;
        }
        return returnresult($msg,$result) ; 
    }

}